package thread;
/**线程的优先级
 * 线程有10个优先级,分别用整数1-10表示.其中1为最低,5为默认,10为最高优先级
 *
 * 当线程调用start方法后就纳入*/
public class PriorityDemo {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        Thread min = new Thread(()->{
            for (int i = 0; i < 100; i++) {
                System.out.println("min");
            }
            long end = System.currentTimeMillis();
            System.out.println("min执行时间:"+(end-start));
        });
        Thread nor = new Thread(()->{
            for (int i = 0; i < 100; i++) {
                System.out.println("nor");
            }
            long end = System.currentTimeMillis();
            System.out.println("nor执行时间:"+(end-start));
        });
        Thread max = new Thread(()->{
            for (int i = 0; i < 100; i++) {
                System.out.println("max");
            }
            long end = System.currentTimeMillis();
            System.out.println("max执行时间:"+(end-start));
        });
        min.setPriority(Thread.MIN_PRIORITY);//设置优先级
        max.setPriority(Thread.MAX_PRIORITY);//设置优先级

        min.start();
        nor.start();
        max.start();
    }
}
